package emergence.game.gfx;

import java.util.HashMap;
import java.util.Map;

import emergence.game.Game;

public class Font {
	
	private static String chars = 
			"ABCDEFGHIJKLMNOPQRSTUVWXYZ      " 
			+ "0123456789.,:;'\"!?$%()-=+/      ";

	
	public static void render(String msg, Screen screen, int x, int y, int color, int scale) {
		msg = msg.toUpperCase();
		
		for (int i = 0; i < msg.length(); i++) {
			int charIndex = chars.indexOf(msg.charAt(i));
			if (charIndex >= 0) {
				screen.render(x + i * 8, y, new ColoredSprite(charMap.get(msg.charAt(i)), color), scale);
			}
		}
	}
	
	
	public static void initFont() {
		SpriteSheet sheet = Game.sheet;
		charMap.put('0', sheet.getBasicSprite(0, 31));
		charMap.put('1', sheet.getBasicSprite(1, 31));
		charMap.put('2', sheet.getBasicSprite(2, 31));
		charMap.put('3', sheet.getBasicSprite(3, 31));
		charMap.put('4', sheet.getBasicSprite(4, 31));
		charMap.put('5', sheet.getBasicSprite(5, 31));
		charMap.put('6', sheet.getBasicSprite(6, 31));
		charMap.put('7', sheet.getBasicSprite(7, 31));
		charMap.put('8', sheet.getBasicSprite(8, 31));
		charMap.put('9', sheet.getBasicSprite(9, 31));
	}
	
	private static Map<Character, Sprite> charMap = new HashMap<>();
}
